{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            {foreach name="config" item="config"}
            <div class="layui-form-item">
                <label class="layui-form-label">{$config.title}</label>
                <div class="layui-input-inline">
                    {if $config.type eq 'input'}
                    <input type="text" name="{$config.name}" value="{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}" placeholder="请输入{$config.title}" class="layui-input">
                    {/if}
                    {if $config.type eq 'textarea'}
                    <textarea name="{$config.name}" placeholder="请输入{$config.title}" class="layui-textarea">{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}</textarea>
                    {/if}
                    {if $config.type eq 'select'}
                    {if $config.is_sys eq '1'}
                    <select name="{$config.name}">
                        {foreach name=":parse_attr($config.options)" key="i" item="j"}
                        <option value="{$i}" {if condition="$data[$config.name] eq $i"}selected="selected"{/if}>{$j}</option>
                        {/foreach}
                    </select>
                    {else}
                    <select name="{$config.name}">
                        {foreach name=":parse_attr($config.options)" key="i" item="j"}
                        <option value="{$i}" {if condition="$data.jdata[$config.name] eq $i"}selected="selected"{/if}>{$j}</option>
                        {/foreach}
                    </select>
                    {/if}
                    {/if}
                    {if $config.type eq 'radio'}
                    {foreach name=":parse_attr($config.options)" key="i" item="j"}
                    <input type="radio" name="{$config.name}" value="{$i}" title="{$j}" {if condition="$data.jdata[$config.name] eq $i"}checked="checked"{/if}>
                    {/foreach}
                    {/if}
                    {if $config.type eq 'image'}
                    <input type="text" name="{$config.name}" value="{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}" autocomplete="off" placeholder="请上传{$config.title}" class="layui-input">
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-position ajax-images"><i class="fa fa-file-image-o"></i> 选择图片</button>
                    {/if}
                </div>
                {if $config.is_sys eq '1'}
                <div class="layui-form-mid layui-word-aux"><a class="layui-btn layui-btn-xs" href="{:url('user/config/index')}">设置参数值</a></div>
                {/if}
            </div>
            {/foreach}
            <div class="layui-form-item">
                <label class="layui-form-label">备注信息</label>
                <div class="layui-input-block">
                    <textarea name="remark" class="layui-textarea" style="height:200px;">{$data.remark|default=''}</textarea>
                </div>
            </div>
            <hr>
            <div class="layui-form-item">
                <label class="layui-form-label">客户信息</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="update_customer" lay-filter="test" title="同步修改客户基本信息">
                </div>
            </div>
            <div id="myid">
            {foreach name="config_customer" item="config"}
            <div class="layui-form-item">
                <label class="layui-form-label">{$config.title}</label>
                <div class="layui-input-inline">
                    {if $config.type eq 'select'}
                    <select name="customer[{$config.name}]">
                        {foreach name=":parse_attr($config.options)" key="i" item="j"}
                        <option value="{$i}" {if condition="$customer[$config.name] eq $i"}selected="selected"{/if}>{$j}</option>
                        {/foreach}
                    </select>
                    {/if}
                </div>
                {if $config.is_sys eq '1'}
                <div class="layui-form-mid layui-word-aux"><a class="layui-btn layui-btn-xs" href="{:url('user/config/index')}">设置参数值</a></div>
                {/if}
            </div>
            {/foreach}
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="*" lay-submit="">保存</button>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
    $("#myid").hide();
    form.on('checkbox()', function(data){
        //console.log(data.elem.checked); //是否被选中，true或者false
        if(data.elem.checked){
            $("#myid").show();
        }else{
            $("#myid").hide();
        }
    });
</script>
{/block}